<?php

class Admin_Login_Controller extends Base_Controller {

	public function action_index()
	{
		return View::make('admin.login');
	}

	public function action_dologin()
	{

		$username = Input::get('username');
		$password = Input::get('password');
		$result = DB::table('admin')->where("username",'=',$username)->where('password','=',$password)->first();
		if($result){
			$username = Session::put('username',$username);
   			return json_encode(array('code' => 200,'msg' => '登入成功'));
		}else{
			return json_encode(array('code'=> 400,'msg'=>'用户名或者密码错误'));
		}		
	
	}

	public function action_logout()
	{
		Session::forget('username');
        return Redirect::to('/index.php/admin/login');
	}













}